#ifndef CARDENGINE_H
#define CARDENGINE_H

#include <string>
#include <vector>
#include <global.h>

class Card;
class CardSpot;
class CardEngine
{
public:
    virtual ~CardEngine();
    enum Type { Type_None, Type_Klondike };
    int type() const;
    const std::string &name() const;
    static std::vector<CardEngine*> engines();
    // ### extra info, rules and stuff

    virtual void handlePress(const Point &pos);
    virtual void handleDrag(const Point &pos);
    virtual void handleRelease(const Point &pos);
    virtual void windowResized(const Rectangle &rectangle);
    virtual std::vector<Card*> grabCard(Card *card) const = 0; // ### const?
protected:
    virtual bool canDrop(const Card *card, const CardSpot *spot) const;
    virtual bool drop(Card *card, CardSpot *spot);
    virtual Card *cardAt(const Point &pos) const;
    virtual CardSpot *cardSpotAt(const Point &pos) const;
    virtual std::vector<CardSpot *> cardSpotsAt(const Rectangle &rect) const;
    virtual Card *pop_deck();
    void reset();
    CardEngine(const std::string &name, int type);
protected:
    std::vector<CardSpot*> cardSpots;
    std::vector<Card*> deck, inplay;
    std::vector<Card*> draggedCards;
    CardSpot *hoveredSpot;
    Point dragOffset, lastMove;
private:
    // int max players 1 => solitaire
    //
    struct Data {
        Data(const std::string &n, int typ) : name(n), type(typ) {}
        const std::string name;
        const int type;
    } data;
    static std::vector<CardEngine*> enginesVector;

};

#endif
